@file:Suppress("DEPRECATION")
package kotlinx.coroutines.script.tes

import android.content.Context
import android.graphics.Point
import android.util.DisplayMetrics
import android.view.WindowManager

private val phoneDefaultDisplay by lazy {
    (appContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay!!
}
val phoneDisplayMetrics by lazy {
    DisplayMetrics().also { phoneDefaultDisplay.getMetrics(it) }
}
val phoneDensityDpi by lazy {
    phoneDisplayMetrics.densityDpi
}
val phoneDefaultDisplayPoint by lazy {
    Point().also { phoneDefaultDisplay.getRealSize(it) }
}
val phoneScreenWidth by lazy {
    val point = phoneDefaultDisplayPoint
    if (point.x > point.y) point.x else point.y
} // 2340 由于是横屏模式.提前反过来
val phoneScreenHeight by lazy {
    val point = phoneDefaultDisplayPoint
    if (point.x > point.y) point.y else point.x
} // 1080 由于是横屏模式.提前反过来

private val pts by lazy { phoneScreenHeight / 1000f } // 以横屏后的高为单位分成1000份
val Int.pt: Int get() {
    if (this == 0) return 0
    val value: Float = (this * pts)
    val out = value.toInt()
    if (out == 0) return this
    return out
}
val Float.pt: Float get() = (this * pts)


